package com.jobsleaf.viewsorter.tree;

import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.part.ViewPart;

import com.jobsleaf.tree.domain.Subnetwork;

public class SubnetworkView extends ViewPart
{
	private SubnetworkLabelProvider mLabelProvider;
	private CheckboxTreeViewer mTreeViewer;
	private Combo mSubnetWorkCombo;


	public void createPartControl(Composite parent)
	{
		parent.setLayout(new GridLayout(1, false));
		mSubnetWorkCombo = new Combo(parent, SWT.READ_ONLY);
		mSubnetWorkCombo.setLayoutData(new GridData(GridData.FILL,
				GridData.FILL, true, false));
		mTreeViewer = new CheckboxTreeViewer(parent);
		mTreeViewer.setContentProvider(new SubnetworkContentProvider());
		mLabelProvider = new SubnetworkLabelProvider();
		mTreeViewer.setLabelProvider(mLabelProvider);
		Tree tree = mTreeViewer.getTree();
		tree.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
				true));
		mTreeViewer.setInput(SubnetworkUtility.getInput());

		for (Subnetwork subnetwork : SubnetworkUtility.getParentList()) {
			mSubnetWorkCombo.add(subnetwork.getName());
		}
		// Add the Sorter to the tree Viewer

		 mTreeViewer.setSorter(new TreeSorter());

	}

	public void setFocus()
	{
	}
}
